import {
	request,
	hotelRequest,
	otherRequest
} from '@/sheep/request';
import $platform from '@/sheep/platform';

export default {


	profile: () =>
		request({
			url: '/user/api/user/profile',
			method: 'GET',
			custom: {
				showLoading: false,
				auth: true,
			},
		}),
	userEncode: (params) =>
		otherRequest({
			url: `/index/encode`,
			method: 'GET',
			params,
			custom: {
				showLoading: false,
				auth: true,
			},
		}),
	update: (data) =>
		request({
			url: '/user/api/user/update',
			method: 'POST',
			custom: {
				showSuccess: true,
				auth: true,
			},
			data,
		}),
	getShopList: (header) =>
		otherRequest({
			url: '/operations/api/getShopList',
			method: 'GET',
			custom: {
				auth: true,
				showError: false
			},
			header,
		}),
	// 账号登录
	accountLogin: (data) =>
		request({
			url: '/user/api/user/accountLogin',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '登录中',
			},
		}),
	// 短信登录
	smsLogin: (data) =>
		request({
			url: '/user/api/user/smsLogin',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '登录中',
			},
		}),
	// 短信注册
	smsRegister: (data) =>
		request({
			url: '/user/api/user/smsRegister',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '正在注册',
			},
		}),
	// 重置密码
	resetPassword: (data) =>
		request({
			url: '/user/api/user/resetPassword',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '验证中',
			},
		}),
	resetPayPassword: (data) =>
		request({
			url: '/user/api/user/resetPayPassword',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '验证中',
			},
		}),
	checkPayPassword: (data) =>
		otherRequest({
			url: '/user/api/user/checkPayPassword',
			method: 'POST',
			data,
			custom: {
				showSuccess: false,
			},
		}),
	// 修改密码
	changePassword: (data) =>
		request({
			url: '/user/api/user/changePassword',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '验证中',
			},
		}),

	// 绑定、更换手机号
	changeMobile: (data) =>
		request({
			url: '/user/api/user/changeMobile',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '验证中',
			},
		}),

	// 修改用户名
	changeUsername: (data) =>
		request({
			url: '/user/api/user/changeUsername',
			method: 'POST',
			data,
			custom: {
				showSuccess: true,
				loadingMsg: '验证中',
			},
		}),

	// 第三方授权信息
	thirdOauthInfo: () =>
		request({
			url: '/user/api/user/thirdOauth',
			method: 'GET',
			params: {
				provider: $platform.provider,
				platform: $platform.platform,
			},
			custom: {
				showLoading: false,
			},
		}),

	// 添加分享记录
	addShareLog: (data) =>
		request({
			url: 'share/add',
			method: 'POST',
			data,
			custom: {
				showError: false,
			},
		}),
	share: {
		list: (params) =>
			request({
				url: 'share/list',
				method: 'GET',
				params,
			}),
	},
	// 账号登出
	logout: (data) =>
		request({
			url: '/user/api/user/logout',
			method: 'POST',
			data,
		}),
	// 账号注销
	logoff: (data) =>
		request({
			url: '/user/api/user/logoff',
			method: 'POST',
			data,
		}),
	// 账号注销
	isMerchant: () =>
		otherRequest({
			url: '/shop/api/task/is_merchant',
			method: 'GET',
		}),	
	address: {
		default: () =>
			otherRequest({
				url: 'user/address/default',
				method: 'GET',
				custom: {
					showError: false,
				},
			}),
		list: () =>
			otherRequest({
				url: 'user/address',
				method: 'GET',
				custom: {},
			}),
		create: (data) =>
			otherRequest({
				url: 'user/address',
				method: 'POST',
				data,
				custom: {
					showSuccess: true,
				},
			}),
		update: (id, data) =>
			otherRequest({
				url: 'user/address/' + id,
				method: 'PUT',
				data,
				custom: {
					showSuccess: true,
				},
			}),
		detail: (id) =>
			otherRequest({
				url: 'user/address/' + id,
				method: 'GET',
			}),
		delete: (id) =>
			otherRequest({
				url: 'user/address/' + id,
				method: 'DELETE',
			}),
	},
	invoice: {
		list: () =>
			request({
				url: 'user/invoice',
				method: 'GET',
				custom: {},
			}),
		create: (data) =>
			request({
				url: 'user/invoice',
				method: 'POST',
				data,
				custom: {
					showSuccess: true,
				},
			}),
		update: (id, data) =>
			request({
				url: 'user/invoice/' + id,
				method: 'PUT',
				data,
				custom: {
					showSuccess: true,
				},
			}),
		detail: (id) =>
			request({
				url: 'user/invoice/' + id,
				method: 'GET',
			}),
		delete: (id) =>
			request({
				url: 'user/invoice/' + id,
				method: 'DELETE',
			}),
	},
	favorite: {
		list: (params) =>
			otherRequest({
				url: 'user/goodsLog/favorite',
				method: 'GET',
				params,
			}),
		do: (id) =>
			otherRequest({
				url: 'user/goodsLog/favorite',
				method: 'POST',
				data: {
					goods_id: id,
				},
				custom: {
					showSuccess: true,
					auth: true,
				},
			}),
		cancel: (id) =>
			otherRequest({
				url: 'user/goodsLog/favorite',
				method: 'POST',
				data: {
					goods_ids: id,
				},
				custom: {
					showSuccess: true,
					auth: true,
				},
			}),
	},
	view: {
		list: (params) =>
			request({
				url: 'user/goodsLog/views',
				method: 'GET',
				params,
				custom: {},
			}),
		delete: (data) =>
			request({
				url: 'user/goodsLog/viewDel',
				method: 'DELETE',
				data,
				custom: {
					showSuccess: true,
				},
			}),
	},
	wallet: {
		log: (params) =>
			otherRequest({
				url: '/user/api/walletLog',
				method: 'GET',
				params,
				custom: {},
			}),
	},
	income: {
		platformRevenue: (params) =>
			request({
				url: '/user/api/income',
				method: 'GET',
				params,
				custom: {
					showLoading: true,
					auth: true,
				},
			}),
		// 我的收益
		myearnings: () =>
			request({
				url: '/shop/api/pet/my',
				method: 'GET',
				custom: {
					showLoading: true,
					auth: true,
				},
			}),
		// 收益列表
		earningsList: (data) =>
			request({
				url: '/shop/api/pet/income/list',
				method: 'POST',
				data,
				custom: {
					showLoading: true,
					auth: true,
				},
			}),
		// 提现
		withdraw: (data) =>
			request({
				url: '/shop/api/pet/withdraw',
				method: 'POST',
				data,
				custom: {
					showLoading: true,
					auth: true,
				},
			}),
		// 收益转余额
		transform: (data) =>
			request({
				url: '/shop/api/pet/transfer',
				method: 'POST',
				data,
				custom: {
					showLoading: true,
					auth: true,
				},
			}),
	},
	account: {
		info: (params) =>
			request({
				url: 'user/account',
				method: 'GET',
				params,
				custom: {
					showError: false,
					auth: true,
				},
			}),
		save: (data) =>
			request({
				url: 'user/account',
				method: 'POST',
				data,
				custom: {
					showSuccess: true,
					auth: true,
				},
			}),
	},
	//数量接口
	data: () =>
		otherRequest({
			url: 'user/user/data',
			method: 'GET',
			custom: {
				showLoading: false,
				auth: true,
			},
		}),
	realname: {
		apply: (data) =>
			request({
				url: '/user/api/user/realname',
				method: 'POST',
				data,
				custom: {
					showError: false,
					auth: true,
				},
			}),
		info: () =>
			request({
				url: '/user/api/user/identityInfo',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
	},
	device: (data) =>
		request({
			url: '/user/api/user/device',
			method: 'POST',
			data,
			custom: {
				showSuccess: false,
				auth: true,
			},
		}),

	org: {
		// 上级和自己
		getTree: (params) =>
			request({
				url: '/user/api/team/myOrganization',
				method: 'get',
				params,
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		// 查看下级
		getNext: (params) =>
			request({
				url: '/user/api/team/teamList',
				method: 'get',
				params,
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),

		// 我邀请的用户
		invite: () =>
			request({
				url: '/user/api/team/invite',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		inviteAward: () =>
			request({
				url: '/user/api/inviteAward',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),

		// 组织架构接口
		orgMain: () =>
			request({
				url: '/user/api/team/main',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		// 查询当前用户下级列表
		teamList: (id) =>
			request({
				url: `/user/api/team/${id}`,
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		getUserTeam: () =>
			request({
				url: `/user/api/team/getTeam`,
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		getTeamChildren: (params) =>
			request({
				url: `/user/api/team/getTeamChildren`,
				method: 'get',
				params,
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		// 团队数据
		teamOverview: () =>
			request({
				url: '/user/api/team/teamOverview',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: true,
				},
			}),
		getCode: () =>
			request({
				url: '/user/api/QrCode/getCode',
				method: 'get',
				custom: {
					showSuccess: false,
					auth: false,
				},
			}),

		userBind: (data) =>
			request({
				url: '/user/api/team/bind',
				method: 'POST',
				data,
				custom: {
					showSuccess: false,
					auth: false,
				},
			}),
	},
	log:{
		goodsLog: (params) =>
			otherRequest({
				url: '/shop/api/user/goodsLog/views',
				method: 'GET',
				params,
				custom: {
					showSuccess: false,
					auth: false,
				},
			}),
		storeLog: (params) =>
			otherRequest({
				url: '/shop/api/user/storeLog/views',
				method: 'GET',
				params,
				custom: {
					showSuccess: false,
					auth: false,
				},
			}),
	}
};